package leetcode.code1131;

public class Solution {
	public int maxAbsValExpr(int[] arr1, int[] arr2) {
		int n1 = arr1[0], n2 = arr2[0];
		int a = n1 + n2;
		int b = n2 - n1;
		int c = n1 - n2;
		int d = -n1 - n2;
		int ans = Integer.MIN_VALUE;
		for (int i = 1; i < arr1.length; i++) {
			n1 = arr1[i];
			n2 = arr2[i];
			int cura = n1 + n2 + i;
			int curb = n2 - n1 + i;
			int curc = n1 - n2 + i;
			int curd = -n1 - n2 + i;
			int curAns = Math.max(Math.max(cura - a, curb - b), Math.max(curc - c, curd - d));
			ans = Math.max(curAns, ans);
			a = Math.min(a, cura);
			b = Math.min(b, curb);
			c = Math.min(c, curc);
			d = Math.min(d, curd);
		}
		return ans;
	}
}
